//
//  TTHeadTitleView.m
//  NJUSTHelper
//
//  Created by 郑越辉 on 2017/9/21.
//  Copyright © 2017年 njust. All rights reserved.
//

#import "TTHeadTitleView.h"
#define WEEK_HEIGHT_SCALE 0.66
#define DATE_HEIGHT_SCALE 0.34
@implementation TTHeadTitleView

-(instancetype)initWithFrame:(CGRect)frame{
    if(self == [super initWithFrame:frame]){
        self.backgroundColor = [UIColor lightGrayColor];
        self.weekLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height * WEEK_HEIGHT_SCALE)];
        [self addSubview:self.weekLabel];
        self.weekLabel.textAlignment = NSTextAlignmentCenter;
        self.weekLabel.textColor = [UIColor whiteColor];
        self.weekLabel.font = [UIFont systemFontOfSize:12];
        self.weekLabel.text = @"周";
        
        
        self.dateLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, frame.size.height * WEEK_HEIGHT_SCALE - 8, frame.size.width, frame.size.height * DATE_HEIGHT_SCALE + 8)];
        [self addSubview:self.dateLabel];
        self.dateLabel.textAlignment = NSTextAlignmentCenter;
        self.dateLabel.textColor = [UIColor whiteColor];
        self.dateLabel.font = [UIFont systemFontOfSize:10];
        self.dateLabel.text = @"9/12";
        
    }
    return self;
}
-(void)setFontColor:(UIColor *)fontColor{
    _fontColor = fontColor;
    self.dateLabel.textColor = fontColor;
    self.weekLabel.textColor = fontColor;
}
-(void)setDate:(NSDate *)date{
    _date = date;
    self.weekLabel.text = [NSString weekStringWithDate:date];
    self.dateLabel.text = [NSString stringWithFormat:@"%@/%@",[NSString monthStringWithDate:date], [NSString dayStringWithDate:date]];
    
}

@end
